// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import ElementUI from 'element-ui'; // 全局引入
// import { Button } from 'element-ui'; // 按需引入
import 'element-ui/lib/theme-chalk/index.css';
import App from './App'
import router from './router'
import store from './store/index'
import {https} from './http-utils/request';
import 'babel-polyfill';
// 通信
import "./utils/postMessageUtil"
import {eventBus} from "./eventBus/bus";
import {formatDate} from './utils/dateFormat';

window._https = https;

Vue.config.productionTip = false // 阻止 vue 在启动时生成生产提示。

Vue.use(ElementUI); // 全局引入
// Vue.use(Button); // 按需引入
/* eslint-disable no-new */
if (window.parent == window && window.opener == null) {
  createVue();
} else if (window.parent != window && window.opener == null) {
  eventBus.bus.$on(eventBus.CHANGE_TABS, createVue)
} else {
  eventBus.bus.$on(eventBus.CHANGE_OPENER, createVue)
}

// 全局过滤器
Vue.filter('formatDate', function (value) {
  return formatDate(value, "yyyy-MM-dd hh:mm:ss")
})

function createVue() {
  new Vue({
    el: '#app',
    router,
    components: {App},
    template: '<App/>',
    store
  })
}
